<?php
/*
# ------------------------------------------------------------------------
# JA Job Board Package
# ------------------------------------------------------------------------
# Copyright (C) 2004-2010 JoomlArt.com. All Rights Reserved.
# @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
# Author: JoomlArt.com
# Websites: http://www.joomlart.com - http://www.joomlancers.com.
# ------------------------------------------------------------------------
*/

// no direct access
defined('_JEXEC') or die('Restricted access');


/**
 * Hello Table class
 *
 * @package    Joomla.Tutorials
 * @subpackage Components
 */
class JobBoardTableJA_PostingPlans extends JTable
{
	/**
	 * Primary Key
	 *
	 * @var int
	 */
	var $id = null;

	/**
	 * @var string
	 */
	var $title = null;
	var $type;
	var $description =null;
	var $price =null;
	var $value = null;
	var $published = 0 ;
	var $enable_tax = 0 ;
	var $ordering = 0;
	

	/**
	 * Constructor
	 *
	 * @param object Database connector object
	 */
	function __construct(& $db) {
		parent::__construct('#__ja_posting_plans', 'id', $db);
	}
	function sub_code_get()
	{
		if($this->id>0)
		{
			$this->sub_code=$this->sub_code_select();
		}
		else 
			$this->sub_code=$this->subscriptions_selectMaxCode()*2;
	}
	function subscriptions_selectMaxCode()
	{
		$db		 =& JFactory::getDBO();
		$query="select max(sub_code) from #__ja_posting_plans";
		$db->setQuery($query);
		$item=$db->loadResult();
		return $item;
	}
	function sub_code_select()
	{
		$db		 =& JFactory::getDBO();
		$query="select sub_code from #__ja_posting_plans where id=".$this->id;
		$db->setQuery($query);
		$item=$db->loadResult();
		return $item;		
	}
	function bind($post){
		return parent::bind($post);
	}
	
	function check(){
		JFilterOutput::objectHTMLSafe($this,ENT_QUOTES,'');
		return true;
	}
		function load($key)
	{
		parent::load($key);
		$this->title = JFilterInput::_decode($this->title);
		$this->title = JFilterInput::clean($this->title);
		return $this;
	}
}